#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <functional>

using namespace std;

#define BEGINS(x) namespace x {
#define ENDS(x) } // end of namespace x

class IQueue {
public:
    virtual void push(int) = 0;

    virtual void pop() = 0;

    virtual bool empty() const = 0;

    virtual int top() const = 0;

    virtual int front() const = 0;

    virtual int size() const = 0;

    virtual ~IQueue();
};

class myQueue : public IQueue {
public:
    myQueue(int n = 5) : __head(0),
                         __tail(0),
                         __count(0),
                         __size(n),
                         __data(new int[__size]) {};

    ~myQueue() {
        if (__data) delete[] __data;
        return;
    }

    void push(int val) override {
        if (__count >= __size) expand();
        __data[__tail++] = val;
        __tail %= __size;
        __count++;
        return;
    }

    void pop() override {
        if (__count == 0) return;
        __head++;
        __head %= __size;
        __count--;
        return;
    }

    int front() const override {
        return __data[__head];
    }

    int size() const override {
        return __count;
    }

    bool empty() const override {
        return __count == 0;
    }

    void swap(myQueue &q) {
        std::swap(this->__head, q.__head);
        std::swap(this->__tail, q.__tail);
        std::swap(this->__size, q.__size);
        std::swap(this->__count, q.__count);
        std::swap(this->__data, q.__data);
        return;
    }

    friend ostream &operator<<(ostream &out, const myQueue &q);

private:
    int __head, __tail, __count, __size;
    int *__data;

    void expand() {
        myQueue q(2 * __size);
        while (this->empty()) {
            q.push(this->front());
            this->pop();
        }
        this->swap(q);
        return;
    }

    int top() const override {
        this->front();
    }
};

class mypriority_queue : public IQueue {
public:
    mypriority_queue(int size = 10, function<bool(int, int)> cmp = less<int>()) : __count(0), __size(size), __data(new int(__size)),
                                                                    __cmp(cmp) {
        __data -= 1;
    }

    ~mypriority_queue() {
        if (__data) {
            __data += 1;
            delete[] __data;
        }
    }

    void push(int val) override {
        if (__count >= __size) {
            expand();
        }
        __data[__count++] = val;
        up_maintain();
    }

    void pop() override {
        if (__count == 0) return;
        std::swap(__data[0], __data[__count]);
        down_maintain();
    }

    bool empty() const override {
        return __count == 0;
    }

    int top() const override {
        return __data[0];
    }

    int size() const override {
        return __count;
    }

    void swap(mypriority_queue &q) {
        std::swap(this->__size, q.__size);
        std::swap(this->__count, q.__count);
        std::swap(this->__data, q.__data);
    }

    friend ostream &operator<<(ostream &out, const mypriority_queue &q);

private:
    int __count, __size;
    int *__data;
    function<bool(int, int)> __cmp;

    void expand() {
        mypriority_queue q(2 * __size, __cmp);
        while (this->empty()) {
            q.push(this->front());
            this->pop();
        }
        this->swap(q);
    }

    int front() const override {
        this->top();
    }

    void up_maintain() {
        int ind = __count;
        while ((ind >> 1) && __cmp(__data[ind >> 1], __data[ind])) {
            std::swap(__data[ind >> 1], __data[ind]);
            ind = ind >> 1;
        }
    }

    void down_maintain() {
        int ind = 1;
        while ((ind << 1) <= __count) {
            int tmp = ind;
            if (__cmp(__data[tmp], __data[tmp] << 1)) tmp = (tmp << 1);
            if ((tmp << 1 | 1) <= __count && __cmp(__data[tmp], __data[tmp << 1 | 1])) tmp = (tmp << 1 | 1);
            if (ind == tmp) break;
            std::swap(__data[tmp], __data[ind]);
        }
    }
};

ostream &operator<<(ostream &out, const myQueue &q) {
    out << "queue : ";
    for (int i = 0, j = q.__head; i < q.__count; i += 1, j += 1) {
        j %= q.__size;
        out << q.__data[j] << " ";
    }
    return out;
}

ostream &operator<<(ostream &out, const mypriority_queue &q) {
    out << "priority_queue : ";
    for (int i = 0; i < q.__count; i += 1) {
        out << (q.__data + 1)[i] << " ";
    }
    return out;
}

bool cmp(int a, int b) {
    return a > b;
}

int main() {
    int op, val;
    myQueue q1;
    mypriority_queue q2;
    mypriority_queue q3(cmp);
    while (cin >> op) {
        switch (op) {
            case 0: {
                cin >> val;
                q1.push(val);
                q2.push(val);
                q3.push(val);
            }
                break;
            case 1: {
                cout << "          queue front : " << q1.front() << endl;
                cout << "   priority(less) top : " << q2.top() << endl;
                cout << "priority(greater) top : " << q3.top() << endl;
                q1.pop();
                q2.pop();
                q3.pop();
            }
                break;
        }
        cout << q1 << endl;
        cout << q2 << endl;
        cout << q3 << endl;
    }
    return 0;

}